package com.sinoglobal.dumping.view;

import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListView;

public class Dumpling_LimitHeightListView extends ListView {

	private boolean haveScrollbar = true;

	public Dumpling_LimitHeightListView(android.content.Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public boolean dispatchTouchEvent(MotionEvent ev) {
		if (ev.getAction() == MotionEvent.ACTION_MOVE) {
			return true;// 禁止listview进行滑动
		}
		return super.dispatchTouchEvent(ev);
	}
	
	/**
	 * 设置不滚动
	 */
	public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

		if (haveScrollbar == true) {
			int expandSpec = MeasureSpec.makeMeasureSpec(
					Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
			super.onMeasure(widthMeasureSpec, expandSpec);

		} else {
			super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		}
	}
}